<template>
	<div class="c-table">
		<el-table :data="tableData" stripe>
			<el-table-column prop="id" label="ID"></el-table-column>
			<el-table-column prop="name" label="用户名称"></el-table-column>

		</el-table>
		<page-num :currentPage="currentPage" :totalPages="totalPages"></page-num>
	</div>
</template>

<script>
	import PageNum from './page_num.vue'
  import {getUsers} from '@/api/admin/user.js'
	export default{
		data() {
			return {
				tableData: [],
        currentPage:1,
        totalPages:null,
			}
		},
		components: {
			PageNum,
		},
		methods: {
      getTableData(){
        this.currentPage = this.$route.query.pageId ? this.$route.query.pageId : 1
        let data = {
          start:this.currentPage
        }
        getUsers(data).then(res => {
          this.tableData = res.data.pageFromJPA.content
          this.totalPages = res.data.totalPages
        })
      }
		},
    created() {
      this.getTableData()
    },
    watch: {
      $route(newValue, oldValue) {
        this.getTableData()
      }
    },
	}
</script>

<style scoped>
	.c-table{
		width: 90%;
		margin: 10px auto;
	}
	.c-table i{
		font-size: 20px;
	}
	.c-table i:hover{
		color: #409EFF;
	}
</style>
